import {getRecord} from "@/api/user";

const record= {
    state: {
        pageNo: 0,
        pageSize: 10,
        records: []
    },
    mutations:{
        SET_RECORDS(state, records) {
            state.records = records
        },
        SET_PAGENO(state, pageNo) {
            state.pageNo = pageNo
        },
        SET_PAGESIZE(state, pageSize) {
            state.pageSize = pageSize
        }
    },
    actions: {
        Record({commit}, username, pageNo, pageSize) {
            return new Promise((resolve, reject) => {
                pageNo = 0
                pageSize = 10
                getRecord(username, pageNo, pageSize).then(res => {
                    commit('SET_RECORDS', res.records)
                    resolve()
                }).catch(error => {
                    reject(error)
                })
            })
        }
    }
}

export default record